﻿Imports System
Imports System.IO
Imports System.Data
Imports System.Data.SqlServerCe
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms
Imports System.Data.Common

Module UserLogDao

    Public Function findUserLogs() As DataTable
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()

        Dim SQL As String = "SELECT USER_NAME FROM eqam_user_log GROUP BY USER_NAME ORDER BY USER_NAME "

        Return LoadData(SQL, paramList)
    End Function

    Public Function getLastLoginId() As DataTable
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()

        Dim SQL As String = "SELECT USER_NAME FROM eqam_user_log ORDER BY LOG_ID DESC "

        Return LoadData(SQL, paramList)
    End Function

    Public Function doCreateLogInLog(ByVal userName As String) As Boolean
        Dim paramList As New Hashtable()

        Dim sql As String = "INSERT INTO eqam_user_log(ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, USER_NAME)" & _
                          " VALUES (@ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @USER_NAME)"

        Dim currentDate As Decimal = pdaUtils.getCurrentDate
        Dim currentTime As Decimal = pdaUtils.getCurrentTime
        'first line        
        paramList.Add("@ADD_BY", _USER_ID)
        paramList.Add("@DATE_ADD", currentDate)
        paramList.Add("@TIME_ADD", currentTime)
        paramList.Add("@DATE_UPDATE", currentDate)
        paramList.Add("@TIME_UPDATE", currentTime)
        paramList.Add("@UPDATE_BY", _USER_ID)
        paramList.Add("@USER_NAME", userName)

        Return ExecuteSQL(sql, paramList)
    End Function
End Module
